{
  "properties" : { },
  "id" : "883f03a3738948c3b912ac49969c10d4",
  "script" : null,
  "groupId" : "ded0996d4aa14841ae2d40edb1fa6d63",
  "name" : "导出设备信息",
  "createTime" : 1727071126670,
  "updateTime" : 1726629654323,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "exportDeviceList",
  "method" : "GET",
  "parameters" : [ {
    "name" : "id",
    "value" : "D8279229554905540079,D2432229890537675001",
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  } ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : null,
  "description" : "",
  "requestBodyDefinition" : {
    "name" : "root",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "Object",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "ip",
      "value" : "1.123.12.90",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    } ]
  },
  "responseBodyDefinition" : {
    "name" : null,
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  }
}
================================
import response
import com.alibaba.excel.EasyExcel
import java.net.URLEncoder
import org.apache.commons.codec.Charsets
import com.kd.ndmp.core.excel.NdmpNetDeviceData
import org.springblade.core.excel.util.ExcelUtil
import org.springblade.common.cache.DictCache
 

List idList = Arrays.asList(id.split(","))
var a = idList.size()

 

List resMap = db.select("""
    select dev.device_type ,
        lin.status catch_status_value ,
        lin.ping_enable ,
        dev.station_type ,
        dev.station_prop ,
        info.device_firm,
        dev.voltage_level ,
        dept.  dept_name,info.device_model_name devicemodelvalue,* from ndmp_device dev
    inner join da_link lin on dev.id = lin.task_id
    left join blade_dept dept on dept.id = dev.dcc_id
    left join ndmp_net_device_model_info info on info.id = dev.device_model_id
    where 1=1 
        <if test="idList.size() != 0">
        and dev.id in
            <foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
""");



resMap.forEach(v -> {
    var deviceType = v.get("deviceType")
    v.put("deviceTypeName", (deviceType == null ? "" : DictCache.getValue("deviceType", deviceType::int)));

    var pingEnable = v.get("pingEnable")
    v.put("pingStatusValue", (pingEnable == null ? "" : DictCache.getValue("pingEnable", pingEnable::int)))

    var stationType = v.get("stationType")
    v.put("stationTypeStr", (stationType == null ? "" : DictCache.getValue("stationType", stationType::int)));

    var stationProp = v.get("stationProp")
    v.put("stationPropStr", (stationProp == null ? "" : DictCache.getValue("stationProp", stationProp::int)));

    var voltageLevel = v.get("voltageLevel")
    v.put("voltageLevelValue", (voltageLevel == null ? "" : DictCache.getValue("voltageLevel", voltageLevel::int)));

    var netRegion = v.get("netRegion")
    v.put("netRegionStr", (netRegion == null ? "" : DictCache.getValue("netRegion", netRegion::int)));

    var accessNetwork = v.get("accessNetwork")
    v.put("accessNetworkStr", (accessNetwork == null ? "" : DictCache.getValue("accessNetwork", accessNetwork::int)));
    var deviceFirm = v.get("deviceFirm")
    
    v.put("deviceFirmName", (deviceFirm == null ? "" : DictCache.getValue("deviceFirm", deviceFirm::int)));
    v.put("deviceModelValue", v.get("deviceModel"));

    v.put("catchStatusValue", "RUNNING".equals(v.get("vatchStatusValue")) ? "已采集" : "未采集");
    v.put("openStatusStr", 1 == v.get("openStatus")::int ? "在运" : "检修");
});


List res = new ArrayList();
for (map in resMap) {
    NdmpNetDeviceData vo = new NdmpNetDeviceData()
    vo.deviceName = map.get("deviceName")
    vo.ip = map.get("ip")
    vo.netRegionStr = map.get("netRegionStr")
    vo.stationPropStr = map.get("stationPropStr")
    vo.stationTypeStr = map.get("stationTypeStr")
    vo.deviceTypeName = map.get("deviceTypeName")
    vo.deptName = map.get("deptName")
    vo.accessNetworkStr = map.get("accessNetworkStr")
    vo.deviceFirmName = map.get("deviceFirmName")
    vo.deviceModelValue = map.get("deviceModelValue")
    vo.voltageLevelValue = map.get("voltageLevelValue")
    vo.catchStatusValue = map.get("catchStatusValue")
    vo.openStatusStr = map.get("openStatusStr")
    vo.pingStatusValue = map.get("pingStatusValue")

    res.add(vo)
}

//response.setHeader("content-type", "application/vnd.ms-excel");

var fileName = URLEncoder.encode("设备列表", "US-ASCII");

response.setHeader("content-disposition", "attachment;filename=" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), NdmpNetDeviceData.class).sheet("设备列表").doWrite(res);